package com.kehutong.applet.app;

import com.kehutong.applet.entity.NavigationEntity;
import com.kehutong.applet.service.AppletMenuService;
import com.kehutong.applet.service.BusinessCallService;
import com.kehutong.common.DoveClient;
import com.kehutong.common.util.Token;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.JSONResult;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.jdbc.JdbcSession;
import org.coraframework.orm.jdbc.Page;

import java.util.List;

/**
 * @program: kht
 * @description: 小程序接口
 * @author: joneron
 * @create: 2021/5/27
 **/
@MvcAction
@ReqMapping("/kht-bin/applet")
public class AppletAction {

    private static final Logger logger = LoggerFactory.getLogger(AppletAction.class);

    @Inject
    AppletMenuService appletMenuService;

    @Inject
    private BusinessCallService businessCallService;

    @Inject
    private DoveClient doveClient;

    @Inject
    private JdbcSession sqlSession;


    @ReqMapping("/businessList")
    public JSONResult businessList(Token token, JSONObject jsonObject) {

        return Result.success(businessCallService.findPage(jsonObject));
    }

    @ReqMapping("/navigation/list")
    public JSONResult list(Token token,JSONObject jsonObject) {

        Page<NavigationEntity> page = sqlSession.findPage(NavigationEntity.class)
                .eq("deleted", false)
                .eq("showStatus",true)
                .page(jsonObject)
                .exe();

        return Result.success(page);
    }


}
